<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 使数组变成交替数组的最少操作数 -->
    <script>
      var minimumOperations = function (nums) {
        let res = 0
        for (let i = 0; i < nums.length; i++) {
          if (i % 2 === 0 && nums[i] % 2 === 0) {
            res++
          } else if (i % 2 !== 0 && nums[i] % 2 !== 0) {
            res++
          }
        }
        return res
      }
      console.log(minimumOperations([3, 1, 3, 2, 4, 3]))
    </script>
  </body>
</html>
